home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / util / moni / Scout-src.lha / netinclude / rpc / rpc_msg.h < prev    next >
C/C++ Source or Header  |  2002-09-16  |  3KB  |  161 lines

  1. #ifndef RPC_RPC_MSG_H
  2. #define RPC_RPC_MSG_H
  3. /*
  4.  * $Id: rpc_msg.h,v 1.1.1.1 2001/11/26 22:21:19 tboeckel Exp $
  5.  *
  6.  * RPC message definition
  7.  *
  8.  * Copyright © 1994 AmiTCP/IP Group,
  9.  *                  Network Solutions Development Inc.
  10.  *                  All rights reserved.
  11.  *
  12.  */
  13. /* @(#)rpc_msg.h    2.1 88/07/29 4.0 RPCSRC */
  14. /*      @(#)rpc_msg.h 1.7 86/07/16 SMI      */
  15.  
  16. /*
  17.  * Copyright (C) 1984, Sun Microsystems, Inc.
  18.  */
  19.  
  20. #define RPC_MSG_VERSION        ((u_long) 2)
  21. #define RPC_SERVICE_PORT    ((u_short) 2048)
  22.  
  23. /*
  24.  * Bottom up definition of an rpc message.
  25.  * NOTE: call and reply use the same overall stuct but
  26.  * different parts of unions within it.
  27.  */
  28.  
  29. enum msg_type {
  30.     CALL=0,
  31.     REPLY=1
  32. };
  33.  
  34. enum reply_stat {
  35.     MSG_ACCEPTED=0,
  36.     MSG_DENIED=1
  37. };
  38.  
  39. enum accept_stat {
  40.     SUCCESS=0,
  41.     PROG_UNAVAIL=1,
  42.     PROG_MISMATCH=2,
  43.     PROC_UNAVAIL=3,
  44.     GARBAGE_ARGS=4,
  45.     SYSTEM_ERR=5
  46. };
  47.  
  48. enum reject_stat {
  49.     RPC_MISMATCH=0,
  50.     AUTH_ERROR=1
  51. };
  52.  
  53. /*
  54.  * Reply part of an rpc exchange
  55.  */
  56.  
  57. /*
  58.  * Reply to an rpc request that was accepted by the server.
  59.  * Note: there could be an error even though the request was
  60.  * accepted.
  61.  */
  62. struct accepted_reply {
  63.     struct opaque_auth    ar_verf;
  64.     enum accept_stat    ar_stat;
  65.     union {
  66.         struct {
  67.             u_long    low;
  68.             u_long    high;
  69.         } AR_versions;
  70.         struct {
  71.             caddr_t    where;
  72.             xdrproc_t proc;
  73.         } AR_results;
  74.         /* and many other null cases */
  75.     } ru;
  76. #define    ar_results    ru.AR_results
  77. #define    ar_vers        ru.AR_versions
  78. };
  79. extern bool_t XDRFUN xdr_accepted_reply(XDR * xdrs, struct accepted_reply * ar);
  80.  
  81. /*
  82.  * Reply to an rpc request that was rejected by the server.
  83.  */
  84. struct rejected_reply {
  85.     enum reject_stat rj_stat;
  86.     union {
  87.         struct {
  88.             u_long low;
  89.             u_long high;
  90.         } RJ_versions;
  91.         enum auth_stat RJ_why;  /* why authentication did not work */
  92.     } ru;
  93. #define    rj_vers    ru.RJ_versions
  94. #define    rj_why    ru.RJ_why
  95. };
  96. extern bool_t XDRFUN xdr_rejected_reply(XDR * xdrs, struct rejected_reply * rr);
  97.  
  98. /*
  99.  * Body of a reply to an rpc request.
  100.  */
  101. struct reply_body {
  102.     enum reply_stat rp_stat;
  103.     union {
  104.         struct accepted_reply RP_ar;
  105.         struct rejected_reply RP_dr;
  106.     } ru;
  107. #define    rp_acpt    ru.RP_ar
  108. #define    rp_rjct    ru.RP_dr
  109. };
  110.  
  111. /*
  112.  * Body of an rpc request call.
  113.  */
  114. struct call_body {
  115.     u_long cb_rpcvers;    /* must be equal to two */
  116.     u_long cb_prog;
  117.     u_long cb_vers;
  118.     u_long cb_proc;
  119.     struct opaque_auth cb_cred;
  120.     struct opaque_auth cb_verf; /* protocol specific - provided by client */
  121. };
  122.  
  123. /*
  124.  * The rpc message
  125.  */
  126. struct rpc_msg {
  127.     u_long            rm_xid;
  128.     enum msg_type        rm_direction;
  129.     union {
  130.         struct call_body RM_cmb;
  131.         struct reply_body RM_rmb;
  132.     } ru;
  133. #define    rm_call        ru.RM_cmb
  134. #define    rm_reply    ru.RM_rmb
  135. };
  136. #define    acpted_rply    ru.RM_rmb.ru.RP_ar
  137. #define    rjcted_rply    ru.RM_rmb.ru.RP_dr
  138.  
  139.  
  140. /*
  141.  * XDR routine to handle a rpc message.
  142.  */
  143. extern bool_t XDRFUN    xdr_callmsg(XDR * xdrs, struct rpc_msg * cmsg);
  144.  
  145. /*
  146.  * XDR routine to pre-serialize the static part of a rpc message.
  147.  */
  148. extern bool_t XDRFUN    xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg);
  149.  
  150. /*
  151.  * XDR routine to handle a rpc reply.
  152.  */
  153. extern bool_t XDRFUN    xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg);
  154.  
  155. /*
  156.  * Fills in the error part of a reply message.
  157.  */
  158. extern void    _seterr_reply(struct rpc_msg *msg, struct rpc_err *error);
  159.  
  160. #endif /* !RPC_RPC_MSG_H */
  161.